package com.meet.controller;

import com.meet.api.dto.request.MeetUserLoginRequestDTO;
import com.meet.api.dto.request.MeetUserRegisterRequestDTO;
import com.meet.api.dto.response.MeetUserLoginResponseDTO;
import com.meet.bizservice.UserBizService;
import com.meet.api.dto.response.MeetUserResponseDTO;
import com.meet.util.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@RestController
public class MeetAuthController {

    @Resource
    private UserBizService userBizService;

    @PostMapping("/auth/register")
    public Result<MeetUserResponseDTO> register(@RequestBody @Validated MeetUserRegisterRequestDTO request) {

        return userBizService.register(request.getUsername(), request.getPassword(),
                request.getPhone(), request.getEmail());
    }

    @PostMapping("/auth/login")
    public Result<MeetUserLoginResponseDTO> login(@RequestBody @Validated MeetUserLoginRequestDTO request) {

        return userBizService.login(request.getUsername(), request.getPassword());
    }

}
